package com.example.controller;

import com.example.entity.supervision.CheckItem;
import com.example.service.CheckItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * Created by simon on 2018/8/7.
 * 检查项管理
 */
@RestController
@RequestMapping("api/checkItem")
public class CheckItemController {

    @Autowired
    CheckItemService checkItemService;


    /**
     * 按条件查询 检查项目字典表
     * @param map
     * @return
     */
    @RequestMapping(value = "/queryCheckItem", method = RequestMethod.POST)
    Map<String, Object> query(@RequestBody Map map) {
        return checkItemService.query(map);
    }


    /**
     * 添加 检查项目（只能是手动添加为自定义的）
     * @param map
     * @return
     */
    @RequestMapping(value = "/addCheckItem", method = RequestMethod.POST)
    Map<String, Object> add(@RequestBody CheckItem map) {
        return checkItemService.add(map);
    }

    /**
     * 删除 检查项目
     * @param map
     * @return
     */
    @RequestMapping(value = "/deleteCheckItem", method = RequestMethod.POST)
    Map<String, Object> closeOrOpen(@RequestBody Map map) {
        return checkItemService.closeOrOpen(map);
    }


    /**
     * excel导入
     * @param file userId
     * @return
     */
    @RequestMapping(value="/importExcel",method = RequestMethod.POST)
    Map<String,Object> inExcel(@RequestBody MultipartFile file, @RequestParam("pDictId") String pDictId){

        return checkItemService.inExcel(file,pDictId);

    }

    /**
     * excel导入
     * @param file userId
     * @return
     */
    @RequestMapping(value="/uploadExcel",method = RequestMethod.POST)
    Map<String,Object> importLoadExcel(@RequestBody MultipartFile file, @RequestParam("pDictId") String pDictId){

        return checkItemService.inExcel(file,pDictId);

    }

    /**
     * 按条件查询 检查项目字典表
     */
    @RequestMapping(value = "/querySpotCheckItem", method = RequestMethod.POST)
    Map<String, Object> querySpotCheckItem(@RequestBody Map map) {

        return checkItemService.querySpotCheckItem(map);
    }

}
